package org.babygo.connect.handler.client.msg;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

import org.babygo.connect.NettyFileOperator;
import org.babygo.connect.util.CommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ClientClosedInHandler extends ChannelInboundHandlerAdapter{
	private Logger log = LoggerFactory.getLogger(ClientClosedInHandler.class);
	
	@Override
	public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
		log.info("[client]Unregistered");
		NettyFileOperator.OPERTATOR.writeLog("[客户端]到" + ctx.channel().remoteAddress().toString() + "的连接被远程关闭!");
		String[] ipAndPort = CommonUtil.getIpAndPort(ctx.channel().remoteAddress());
		NettyFileOperator.OPERTATOR.remotServerConnectClosed(ipAndPort[0],ipAndPort[1]);
	}
}
